#!/bin/bash

base=$1

function scandir() {
    local cur_dir parent_dir workdir
    workdir=$1
    cd ${workdir}
    if [ ${workdir} = "/" ]
    then
        cur_dir=""
    else
        cur_dir=$(pwd)
    fi
    
    for dirlist in $(ls ${cur_dir})
    do
        if test -d ${dirlist};then
            cd ${dirlist}
            scandir ${cur_dir}/${dirlist}
            cd ..
        else
            if [ -f ${cur_dir}/${dirlist} ]; then
                echo "do with file ${cur_dir}/${dirlist}"
                dos2unix ${cur_dir}/${dirlist}
            fi
        fi
    done
}

scandir $base
exit 0

